#ifndef APLAYER_TIMERTHREAD_H
#define APLAYER_TIMERTHREAD_H

#include <functional>

namespace ylw
{

class Timer
{

    using TimerCallback = std::function<void()>;

public:
    Timer(TimerCallback && cb, int, int );
    void start();
    void stop();

private:
    int creatTimerfd();

    void setTimefd(int, int);
    void handleRead();
private:
    int _fd;
    int _initialTime;
    int _periodicTime;
    TimerCallback _cb;
    bool _isStarted;
};

}

#endif
